"""win32 constants that are missing from win32con"""

import ctypes
from enum import IntEnum

# System error codes
ERROR_SUCCESS = 0
ACCESS_DENIED = 5
ERROR_NOT_FOUND = 0x490
ERROR_INVALID_HANDLE = 6
ERROR_INVALID_PARAMETER = 87

# FormatMessage constants
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200

NIM_ADD = 0x0
NIM_MODIFY = 0x1
NIM_DELETE = 0x2
NIM_SETFOCUS = 0x3
NIM_SETVERSION = 0x4

NIF_MESSAGE = 0x1
NIF_ICON = 0x2
NIF_TIP = 0x4
NIF_STATE = 0x8
NIF_INFO = 0x10
NIF_GUID = 0x20
NIF_REALTIME = 0x40
NIF_SHOWTIP = 0x80

NIN_POPUPOPEN = 0x406
NIN_POPUPCLOSE = 0x407
NIN_SELECT = 0x400
NIN_CONTEXTMENU = 0x7B

INVALID_HANDLE_VALUE = ctypes.c_void_p(-1).value

# Common process/query flags
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000

# DWM and window constants
SW_MAXIMIZE = 3
DWMWA_EXTENDED_FRAME_BOUNDS = 9
DWMWA_CLOAKED = 14
S_OK = 0

# DWM thumbnail properties flags
DWM_TNP_RECTDESTINATION = 0x00000001
DWM_TNP_RECTSOURCE = 0x00000002
DWM_TNP_OPACITY = 0x00000004
DWM_TNP_VISIBLE = 0x00000008
DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010

# Constants for locale information
LOCALE_NAME_MAX_LENGTH = 85
LOCALE_SISO639LANGNAME = 0x59
LOCALE_SISO639LANGNAME2 = 0x67
LOCALE_SISO3166CTRYNAME = 0x5A
LOCALE_SLANGUAGE = 0x2
LOCALE_SCOUNTRY = 0x6
LOCALE_SNAME = 0x5C
LOCALE_SNATIVECTRYNAME = 0x07
LOCALE_SNATIVELANGNAME = 0x04
LOCALE_SABBREVLANGNAME = 0x3

# Shell hook HSHELL_* events
HSHELL_WINDOWCREATED = 1
HSHELL_WINDOWDESTROYED = 2
HSHELL_WINDOWACTIVATED = 4
HSHELL_GETMINRECT = 5
HSHELL_REDRAW = 6
HSHELL_TASKMAN = 7
HSHELL_LANGUAGE = 8
HSHELL_SYSMENU = 9
HSHELL_ENDTASK = 10
HSHELL_ACCESSIBILITYSTATE = 11
HSHELL_APPCOMMAND = 12
HSHELL_WINDOWREPLACED = 13
HSHELL_WINDOWREPLACING = 14
HSHELL_RUDEAPPACTIVATED = 32772
HSHELL_FLASH = 32774
HSHELL_FULLSCREENENTER = 53
HSHELL_FULLSCREENEXIT = 54
HSHELL_MONITORCHANGED = 16

# WinEvent constants for cloak detection and hook flags
EVENT_OBJECT_CLOAKED = 0x8017
EVENT_OBJECT_UNCLOAKED = 0x8018
EVENT_OBJECT_SHOW = 0x8002
EVENT_OBJECT_HIDE = 0x8003
WINEVENT_OUTOFCONTEXT = 0x0000
WINEVENT_SKIPOWNPROCESS = 0x0002

# WiFi constants
WLAN_INTERFACE_STATE_CONNECTED = 1
WLAN_INTF_OPCODE_CURRENT_CONNECTION = 7

ERROR_NDIS_DOT11_POWER_STATE_INVALID = 0x80342002

WLAN_AVAILABLE_NETWORK_CONNECTED = 0x1
WLAN_AVAILABLE_NETWORK_HAS_PROFILE = 0x2

WLAN_NOTIFICATION_SOURCE_NONE = 0x0
WLAN_NOTIFICATION_SOURCE_ACM = 0x8
WLAN_NOTIFICATION_SOURCE_ALL = 0xFFFF

DOT11_AUTH_ALGO_80211_OPEN = 1
DOT11_AUTH_ALGO_RSNA_PSK = 7
DOT11_AUTH_ALGO_WPA3_SAE = 9

DOT11_BSS_TYPE_INFRASTRUCTURE = 1

# File change notification constants
FILE_NOTIFY_CHANGE_FILE_NAME = 0x00000001
FILE_NOTIFY_CHANGE_DIR_NAME = 0x00000002
FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x00000004
FILE_NOTIFY_CHANGE_SIZE = 0x00000008
FILE_NOTIFY_CHANGE_LAST_WRITE = 0x00000010
WAIT_OBJECT_0 = 0
WAIT_FAILED = 0xFFFFFFFF
INFINITE = 0xFFFFFFFF
SHERB_NOCONFIRMATION = 0x00000001
SHERB_NOPROGRESSUI = 0x00000002
SHERB_NOSOUND = 0x00000004

# File / CreateFile flags and share modes (useful for directory watches)
FILE_LIST_DIRECTORY = 0x0001
FILE_SHARE_READ = 0x00000001
FILE_SHARE_WRITE = 0x00000002
FILE_SHARE_DELETE = 0x00000004
OPEN_EXISTING = 0x00000003
FILE_FLAG_BACKUP_SEMANTICS = 0x02000000

# SHGSI flags
SHGSI_ICON = 0x000000100
SHGSI_LARGEICON = 0x000000000


class WlanNotificationAcm(IntEnum):
    """WLAN Auto Configuration Manager (ACM) notification codes"""

    AUTOCONF_ENABLED = 0x1
    AUTOCONF_DISABLED = 0x2
    BACKGROUND_SCAN_ENABLED = 0x3
    BACKGROUND_SCAN_DISABLED = 0x4
    BSS_TYPE_CHANGE = 0x5
    POWER_SETTING_CHANGE = 0x6
    SCAN_COMPLETE = 0x7
    SCAN_FAIL = 0x8
    CONNECTION_START = 0x9
    CONNECTION_COMPLETE = 0xA
    CONNECTION_ATTEMPT_FAIL = 0xB
    FILTER_LIST_CHANGE = 0xC
    INTERFACE_ARRIVAL = 0xD
    INTERFACE_REMOVAL = 0xE
    PROFILE_CHANGE = 0xF
    PROFILE_NAME_CHANGE = 0x10
    PROFILES_EXHAUSTED = 0x11
    NETWORK_NOT_AVAILABLE = 0x12
    NETWORK_AVAILABLE = 0x13
    DISCONNECTING = 0x14
    DISCONNECTED = 0x15
    ADHOC_NETWORK_STATE_CHANGE = 0x16
    PROFILE_UNBLOCKED = 0x17
    SCREEN_POWER_CHANGE = 0x18
    PROFILE_BLOCKED = 0x19
    SCAN_LIST_REFRESH = 0x1A


class KnownCLSID:
    """Known Windows shell folder CLSIDs"""

    RECYCLE_BIN = "645FF040-5081-101B-9F08-00AA002F954E"
    THIS_PC = "20D04FE0-3AEA-1069-A2D8-08002B30309D"
    CONTROL_PANEL = "26EE0668-A00A-44D7-9371-BEB064C98683"
    NETWORK = "F02C1A0D-BE21-4350-88B0-7367FC96EF3C"
    USER_FILES = "59031A47-3F72-44A7-89C5-5595FE6B30EE"
    DOCUMENTS_LIBRARY = "7B0DB17D-9CD2-4A93-9733-46CC89022E7C"
    MUSIC_LIBRARY = "2112AB0A-C86A-4FFE-A368-0DE96E47012E"
    PICTURES_LIBRARY = "A990AE9F-A03B-4E80-94BC-9912D7504104"
    VIDEOS_LIBRARY = "491E922F-5643-4AF4-A7EB-4E7A138D8174"
    QUICK_ACCESS = "679F85CB-0220-4080-B29B-5540CC05AAB6"
